<?php


namespace App\Models;
use App\Http\Controllers\Es\EsController;

class Index
{
    public function index()
    {
        //获取最新的新闻
        $newsData = EsController::getInstance()->queryData(config('index.news'));
        //获取今日油价
        $oilPrices = new OilPrice();
        return [
            'name' => ['张三','李四','王二'],
            'news' => isset($newsData['hits']['hits'])&&!empty($newsData['hits']['hits']) ? $newsData['hits']['hits'] : [],
            //'oilPrices' => $oilPrices->indexOilPrice()
        ];
    }
    public function getData()
    {
        $newsData = EsController::getInstance()->queryData(config('index.news'));
        return $newsData;
    }
}